package com.ygxsk.carhome.ui.adapter;

import android.text.TextUtils;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.StringUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.enumwrap.FileSignatureBoxStatus;
import com.ygxsk.carhome.response.InformationManage;
import com.ygxsk.carhome.utils.CommUtils;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-11-06  15:03
 * @Description:添加适配器 客户档案的主要列表
 */
public class ArchiveFileItemToAdapter extends BaseQuickAdapter<InformationManage, BaseViewHolder> {

    public ArchiveFileItemToAdapter(int layoutResId, @Nullable List<InformationManage> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, InformationManage informationManage) {

        if (informationManage != null) {

            //签约时间
            String createTime = informationManage.getCreateTime();
            //档案编号
            String createSerialNo = informationManage.getInformationNo();
            //合同模板--2023年10月30日15:45:14暂时改动为 店铺名称
            //String signTemplateName = fileSignatureManage.getSignTemplateName();

            //所在园区的名称
            String communityName = informationManage.getCommunityName();
            //店铺名称：
            String signTemplateName = informationManage.getShopInfoName();

            String resultShopName = "";

            if (!TextUtils.isEmpty(communityName)) {
                resultShopName = signTemplateName + StringUtils.getString(R.string.kongge0) + StringUtils.getString(R.string.bracket_left_small) + communityName + StringUtils.getString(R.string.bracket_right_small);
            } else {
                resultShopName = signTemplateName;
            }

            //乙方名称--也即是 客户名称
            String clientName = informationManage.getClientName();

            //客户手机号
            String clientPhone = informationManage.getClientPhone();

//             enum FileSignatureBoxStatus {
//                //审核状态   0填写中，1待审核  2通过  3不通过
//                AUDITSTATUS_FILL("0"),//
//                AUDITSTATUS_TO_BE_REVIEWED("1"),//
//                AUDITSTATUS_PASSED("2"),//
//                AUDITSTATUS_FAILED("3");//

            //档案状态  数值状态
            String auditStatus = informationManage.getAuditStatus();
            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "--auditStatus-->" + auditStatus);

            //档案状态  汉字状态
            String auditStatusInfo = "";

            if (!TextUtils.isEmpty(auditStatus)) {

                if (TextUtils.equals(auditStatus, FileSignatureBoxStatus.AUDITSTATUS_FILL.getIndex())) {

                    //填写中
                    auditStatusInfo = FileSignatureBoxStatus.AUDITSTATUS_FILL.getValue();

                } else if (TextUtils.equals(auditStatus, FileSignatureBoxStatus.AUDITSTATUS_TO_BE_REVIEWED.getIndex())) {

                    //待审核
                    auditStatusInfo = FileSignatureBoxStatus.AUDITSTATUS_TO_BE_REVIEWED.getValue();

                } else if (TextUtils.equals(auditStatus, FileSignatureBoxStatus.AUDITSTATUS_PASSED.getIndex())) {

                    //通过
                    auditStatusInfo = FileSignatureBoxStatus.AUDITSTATUS_PASSED.getValue();


                } else if (TextUtils.equals(auditStatus, FileSignatureBoxStatus.AUDITSTATUS_FAILED.getIndex())) {

                    //不通过
                    auditStatusInfo = FileSignatureBoxStatus.AUDITSTATUS_FAILED.getValue();

                }

            }

            //签约时间
            TextView textViewFileSignCreateTime = (TextView) baseViewHolder.getView(R.id.textviewfilesigncreatetime_archive);
            //合同编号
            TextView textViewFileArchivesInDocment = (TextView) baseViewHolder.getView(R.id.textviewfilesignature_archive);
            //模板名称
            TextView textViewFileSignTemplateName = (TextView) baseViewHolder.getView(R.id.textViewFileSignTemplateName_archive);
            //乙方姓名
            TextView textViewFileSignPartyBName = (TextView) baseViewHolder.getView(R.id.textViewFileSignPartyBName_archive);
            //乙方电话
            TextView textViewFileSignPartyBPhone = (TextView) baseViewHolder.getView(R.id.textViewFileSignPartyBPhone_archive);
            //档案状态
            TextView textViewFileSignContractStatus = (TextView) baseViewHolder.getView(R.id.textViewFileSignContractStatus_archive);

            //一条帮助横线用于在显示隐藏的时候用到
//          TextView textViewLineToptoButtons = (TextView) baseViewHolder.getView(R.id.textViewLineToptoButtons);

            //签约时间
            CommUtils.setText(textViewFileSignCreateTime, createTime);
            //档案编号
            CommUtils.setText(textViewFileArchivesInDocment, createSerialNo);
            //模板名称--2023年10月30日15:58:37改为店铺名称
            CommUtils.setText(textViewFileSignTemplateName, resultShopName);
            //乙方姓名,客户姓名
            CommUtils.setText(textViewFileSignPartyBName, clientName);
            //乙方电话
            CommUtils.setText(textViewFileSignPartyBPhone, clientPhone);
            //档案状态
            CommUtils.setText(textViewFileSignContractStatus, auditStatusInfo);

//            if (extra_jumpfrom_where == ExtraValue.VALUE_JUMPFROM_SIGNATURE_ACTIVITY_ONITEM_CLICK_INTO) {
//                //正常的管理页进入
//                linearLayoutTwoWrapButtons.setVisibility(View.VISIBLE);
//                textViewLineToptoButtons.setVisibility(View.VISIBLE);
//
//            } else if (extra_jumpfrom_where == ExtraValue.VALUE_JUMPFROM_SIGNATURE_HISTROY_ACTIVITY_ONITEM_CLICK_INTO) {
//
//                //历史记录进入
//                linearLayoutTwoWrapButtons.setVisibility(View.GONE);
//                textViewLineToptoButtons.setVisibility(View.GONE);
//            }

        }

    }
}
